﻿namespace _3_NovaAdmin.Domain.Abstractions;

/// <summary>
/// 主仓储接口（默认主键类型Guid）
/// </summary>
/// <typeparam name="TEntity"></typeparam>
public interface IRepository<TEntity> : IRepository<TEntity, Guid> where TEntity : IEntity<Guid>
{

}

/// <summary>
/// 通用仓储接口（有唯一主键）
/// </summary>
/// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TKey"></typeparam>
public interface IRepository<TEntity, TKey> : IBaseRepository<TEntity> where TEntity : IEntity<TKey> where TKey : notnull
{
    /// <summary>
    /// 批量删除
    /// </summary>
    /// <param name="array"></param>
    /// <returns></returns>
    Task<bool> DeleteArray(List<TKey> array);

    /// <summary>
    /// 批量添加
    /// </summary>
    /// <param name="array"></param>
    /// <returns></returns>
    Task<bool> InsertManyData(List<TEntity> array);

    /// <summary>
    /// 根据id查询单条数据
    /// </summary>
    /// <param name="id"></param>
    /// <returns></returns>
    Task<TEntity> QuerySingleData(TKey id);

    /// <summary>
    /// 修改单条数据
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    Task UpdateSingleData(TEntity data);

    /// <summary>
    /// 添加单条数据
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    Task InsertSingleData(TEntity data);

    /// <summary>
    /// 添加/修改单条数据
    /// </summary>
    /// <param name="data"></param>
    /// <returns></returns>
    Task<Tuple<bool, int>> InsertOrUpdateSingleData(TEntity data);
}
